package com.example.demo.mapper;

import com.example.demo.entity.File;

import org.apache.ibatis.annotations.*;

import java.util.Map;

@Mapper
public interface FileMapper {

    @Insert("insert into file(path,size,title,summary) values(#{path},#{size},#{title},#{summary})")
    void insertFileWithSum(File file);

    @Insert("insert into file(path,size,title,picture_path_1) values(#{path},#{size},#{title},#{picturePath1})")
    void insertFileWithPic1(File file);

    @Insert("insert into file(path,size,title,summary,picture_path_1,picture_path_2,picture_path_3) values(#{path},#{size},#{title},#{summary},#{picturePath1},#{picturePath2},#{picturePath3})")
    void insertNote(File file);

    @Select("select * from file where path=#{path}")
    File selectFileByPath(String path);

    @Update("update file set be_star=1 where path=#{path}")
    Integer fileAddStar(String path);

    @Update("update file set be_star=0 where path=#{path}")
    Integer fileCancelStar(String path);

    @Update("update file set be_top=1 where path=#{path}")
    Integer fileAddTop(String path);

    @Update("update file set be_top=0 where path=#{path}")
    Integer fileCancelTop(String path);

    @Update("update file set last_update_datetime=#{time} where path=#{path}")
    Integer fileUpdateLastTime(String time,String path);

    @Select("select * from fileFolder where path=#{path}")
    Map<String,Object> getFileInfo(String path);

    @Update("update file set path=#{path},size=#{size},title=#{title},summary=#{summary} where path=#{path}")
    Integer updateFileWithSummary(File file);

    @Update("update file set path=#{path},size=#{size},title=#{title},picture_path_1=#{picturePath1} where path=#{path}")
    Integer updateFileWithPic1(File file);

    @Update("update file set path=#{path},size=#{size},title=#{title},summary=#{summary},picture_path_1=#{picturePath1},picture_path_2=#{picturePath2},picture_path_3=#{picturePath3} where path=#{path}")
    void updatetNote(File file);

    @Update("update file set author=#{author},origin=#{origin} where path=#{path}")
    Integer updateFileWithAuthor(File file);

    @Update("update file set title =#{title} where path=#{path}")
    Integer updateFileTitle(String title,String path);
}
